/**
* Copyright (c) 2015 
* All rights reserved.  
*  
* @file       gui_fillpolygon.c  
* @brief      Fill polygon routine
* @author  wangjj
* @Email    
* @date     2015-12-1 
* @version 1.0  
*/

#include <cdefBf531.h>
#include <ccblkfn.h>
#include <string.h>
#include "Assistant.h"
#include "DPX.h"
#include "gui.h"
#include "Icon.h"
#include "AcqView.h"


static const unsigned short acBANDWIDTH[] = {
  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
  0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF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FFFF, 0xFFFF,
  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF
};

const GUI_BITMAP bmBANDWIDTH = {
  16, /* XSize */
  16, /* YSize */
  32, /*BytesPerLine*/
  (const unsigned char *)acBANDWIDTH,  /* Pointer to picture data */
};


static void _DrawBitLine(int x, int y, const unsigned short *p, unsigned short xsize)
{
    unsigned short pixel;
    
    /* check if over screen */
    if(x < 0)
        x = 0;    
    if((x + xsize) > GUI_X_RES)
        xsize = GUI_X_RES - x;

    for (; xsize > 0; xsize--, x++, p++)
    {
        pixel = *p;
        //if(pixel)
        {
            GUI_SetPixel(x, y, *p);
        }
    }
    
}


/*********************************************************************
*
*       GUI_DrawBitmap
*/
void GUI_DrawBitmap(const GUI_BITMAP  *pBitmap, int x0, int y0) 
{
    int i,x1,y1;
    unsigned short ysize = pBitmap->YSize;
    unsigned char *pData = (unsigned char *)pBitmap->pData;
    
    if((y0 + ysize) > GUI_Y_RES)
    {
        ysize = GUI_Y_RES - y0;
    }

    for (i=0; i< ysize; i++)
    {
        _DrawBitLine(x0, i + y0, (const unsigned short *)pData, pBitmap->XSize);
        pData += pBitmap->BytesPerLine;
    }

}







